package com.manager.commons;


import java.util.ArrayList;
import java.util.List;

/**
 * 常量
 *
 * @author H
 */
public class Constant {

    /**
     * 登录用户Session
     */
    public static final String LOGIN_USER_SESSION = "LOGIN_USER_SESSION";

    /**
     * 日志操作者
     */
    public static final String LOG_OPERATOR = "LOG_OPERATOR";
    /**
     * 文件类型
     */
    public enum FileType {
        FOLDER("dir", "文件夹"), FILE("file", "文件");

        private String ecode;
        private String ename;

        FileType(String code, String vname) {
            this.ecode = code;
            this.ename = vname;
        }

        public String getEcode() {
            return ecode;
        }

        public void setEcode(String ecode) {
            this.ecode = ecode;
        }

        public String getEname() {
            return ename;
        }

        public void setEname(String ename) {
            this.ename = ename;
        }

        public static String formName(String state) {
            FileType[] s = FileType.values();
            for (FileType ct : s) {
                if (ct.getEcode().equals(state)) {
                    return ct.getEname();
                }
            }
            return FILE.ename;
        }
        public static List<String> enames() {
            FileType[] s = FileType.values();
            List<String> list = new ArrayList<>();
            for (FileType ct : s) {
                list.add(ct.getEname());
            }
            return list;
        }
    }
    /**
     * 数据状态
     */
    public enum DbStatus {
        DELETE("-2", "删除"), DISABLE("-1", "禁用"), ENABLE("1", "正常"),
        HIDE("2", "隐藏");

        private String ecode;
        private String ename;

        DbStatus(String code, String vname) {
            this.ecode = code;
            this.ename = vname;
        }

        public String getEcode() {
            return ecode;
        }

        public void setEcode(String ecode) {
            this.ecode = ecode;
        }

        public String getEname() {
            return ename;
        }

        public void setEname(String ename) {
            this.ename = ename;
        }
    }
    /**
     * 订单状态
     */
    public enum OrderStatus {
        NO_PAY("0", "待支付"), YES_PAY("1", "已支付"), CANCEL_PAY("2", "已取消"),REFUND_PAY("3","退款中"),REFUND_PAY_SUCCESS("4","已退款"),
        UNKNOWN("0", "未知");

        private String ecode;
        private String ename;

        OrderStatus(String code, String vname) {
            this.ecode = code;
            this.ename = vname;
        }

        public String getEcode() {
            return ecode;
        }

        public void setEcode(String ecode) {
            this.ecode = ecode;
        }

        public String getEname() {
            return ename;
        }

        public void setEname(String ename) {
            this.ename = ename;
        }

        public static String formName(String state) {
            OrderStatus[] s = OrderStatus.values();
            for (OrderStatus ct : s) {
                if (ct.getEcode().equals(state)) {
                    return ct.getEname();
                }
            }
            return UNKNOWN.ename;
        }
        public static List<String> enames() {
            OrderStatus[] s = OrderStatus.values();
            List<String> list = new ArrayList<>();
            for (OrderStatus ct : s) {
                list.add(ct.getEname());
            }
            return list;
        }
    }
    /**
     * 服装尺码
     */
    public enum ClothingSize {
        XS("1", "XS"), S("2", "S"), M("3", "M"),
        L("4", "L"), XL("5", "XL"), XXL("6", "2XL"), XXXL("7", "3XL"), XXXXL("8", "4XL"),
        UNKNOWN("0", "未知");

        private String ecode;
        private String ename;

        ClothingSize(String code, String vname) {
            this.ecode = code;
            this.ename = vname;
        }

        public String getEcode() {
            return ecode;
        }

        public void setEcode(String ecode) {
            this.ecode = ecode;
        }

        public String getEname() {
            return ename;
        }

        public void setEname(String ename) {
            this.ename = ename;
        }

        public static String formName(String state) {
            ClothingSize[] s = ClothingSize.values();
            for (ClothingSize ct : s) {
                if (ct.getEcode().equals(state)) {
                    return ct.getEname();
                }
            }
            return UNKNOWN.ename;
        }
        public static List<String> enames() {
            ClothingSize[] s = ClothingSize.values();
            List<String> list = new ArrayList<>();
            for (ClothingSize ct : s) {
                list.add(ct.getEname());
            }
            return list;
        }
    }

    /**
     * 血型
     */
    public enum BloodType {
        A("1", "A型"), B("2", "B型"), AB("3", "AB型"), O("4", "O型"),
        UNKNOWN("0", "不清楚");

        private String ecode;
        private String ename;

        BloodType(String code, String vname) {
            this.ecode = code;
            this.ename = vname;
        }

        public String getEcode() {
            return ecode;
        }

        public void setEcode(String ecode) {
            this.ecode = ecode;
        }

        public String getEname() {
            return ename;
        }

        public void setEname(String ename) {
            this.ename = ename;
        }

        public static String formName(String state) {
            BloodType[] s = BloodType.values();
            for (BloodType ct : s) {
                if (ct.getEcode().equals(state)) {
                    return ct.getEname();
                }
            }
            return UNKNOWN.ename;
        }
        public static List<String> enames() {
            BloodType[] s = BloodType.values();
            List<String> list = new ArrayList<>();
            for (BloodType ct : s) {
                list.add(ct.getEname());
            }
            return list;
        }
    }

    /**
     * 性别
     */
    public enum Sex {
        MALE("1", "男"), FEMALE("2", "女"), UNKNOWN("0", "未知");

        private String ecode;
        private String ename;

        Sex(String ecode, String ename) {
            this.ecode = ecode;
            this.ename = ename;
        }

        public String getEcode() {
            return ecode;
        }

        public void setEcode(String ecode) {
            this.ecode = ecode;
        }

        public String getEname() {
            return ename;
        }

        public void setEname(String ename) {
            this.ename = ename;
        }

        public static String formName(String state) {
            Sex[] s = Sex.values();
            for (Sex ct : s) {
                if (ct.getEcode().equals(state)) {
                    return ct.getEname();
                }
            }
            return UNKNOWN.ename;
        }
        public static List<String> enames() {
            Sex[] s = Sex.values();
            List<String> list = new ArrayList<>();
            for (Sex ct : s) {
                list.add(ct.getEname());
            }
            return list;
        }
    }

    /**
     * 是否
     */
    public enum NoOrYes {
        NO("0", "否"), YES("1", "是");

        private String ecode;
        private String ename;

        NoOrYes(String ecode, String ename) {
            this.ecode = ecode;
            this.ename = ename;
        }

        public String getEcode() {
            return ecode;
        }

        public void setEcode(String ecode) {
            this.ecode = ecode;
        }

        public String getEname() {
            return ename;
        }

        public void setEname(String ename) {
            this.ename = ename;
        }

        public static String formName(String state) {
            if (NoOrYes.YES.ecode.equals(state)) {
                return NoOrYes.YES.getEname();
            }
            return NO.ename;
        }
        public static List<String> enames() {
            NoOrYes[] s = NoOrYes.values();
            List<String> list = new ArrayList<>();
            for (NoOrYes ct : s) {
                list.add(ct.getEname());
            }
            return list;
        }
    }

    /**
     * 证件类型
     */
    public enum CertificateType {
        IDCARD("1", "居民身份证"), GATXZ("1", "港澳居民往来内地通行证"), TWTXZ("2", "台湾居民来往大陆通行证"), PASSPORT("3", "护照/Passport"),
        GAJJZ("4", "港澳居民居住证"), TWJJZ("4", "台湾居民居住证"), UNKNOWN("0", "其他");

        private String ecode;
        private String ename;

        CertificateType(String ecode, String ename) {
            this.ecode = ecode;
            this.ename = ename;
        }

        public String getEcode() {
            return ecode;
        }

        public void setEcode(String ecode) {
            this.ecode = ecode;
        }

        public String getEname() {
            return ename;
        }

        public void setEname(String ename) {
            this.ename = ename;
        }

        public static String formName(String state) {
            CertificateType[] s = CertificateType.values();
            for (CertificateType ct : s) {
                if (ct.getEcode().equals(state)) {
                    return ct.getEname();
                }
            }
            return UNKNOWN.ename;
        }

        public static List<String> enames() {
            CertificateType[] s = CertificateType.values();
            List<String> list = new ArrayList<>();
            for (CertificateType ct : s) {
                list.add(ct.getEname());
            }
            return list;
        }
    }

    /**
     * 证件类型
     */
    public enum RELATIONSHIP {
        FRIEND("1", "朋友"), COUPLE("1", "夫妻"), LOVERS("2", "情侣"), PARENTS("3", "父母"),
        CHILDREN("4", "子女"), UNKNOWN("0", "其他");

        private String ecode;
        private String ename;

        RELATIONSHIP(String ecode, String ename) {
            this.ecode = ecode;
            this.ename = ename;
        }

        public String getEcode() {
            return ecode;
        }

        public void setEcode(String ecode) {
            this.ecode = ecode;
        }

        public String getEname() {
            return ename;
        }

        public void setEname(String ename) {
            this.ename = ename;
        }

        public static String formName(String state) {
            RELATIONSHIP[] s = RELATIONSHIP.values();
            for (RELATIONSHIP ct : s) {
                if (ct.getEcode().equals(state)) {
                    return ct.getEname();
                }
            }
            return UNKNOWN.ename;
        }
        public static List<String> enames() {
            RELATIONSHIP[] s = RELATIONSHIP.values();
            List<String> list = new ArrayList<>();
            for (RELATIONSHIP ct : s) {
                list.add(ct.getEname());
            }
            return list;
        }
    }

    /**
     * 轮播图类型
     */
    public enum ADVERTISINGTYPE {
        HOME("1", "首页"), UNKNOWN("0", "其他");

        private String ecode;
        private String ename;

        ADVERTISINGTYPE(String ecode, String ename) {
            this.ecode = ecode;
            this.ename = ename;
        }

        public String getEcode() {
            return ecode;
        }

        public void setEcode(String ecode) {
            this.ecode = ecode;
        }

        public String getEname() {
            return ename;
        }

        public void setEname(String ename) {
            this.ename = ename;
        }

        public static String formName(String state) {
            ADVERTISINGTYPE[] s = ADVERTISINGTYPE.values();
            for (ADVERTISINGTYPE ct : s) {
                if (ct.getEcode().equals(state)) {
                    return ct.getEname();
                }
            }
            return UNKNOWN.ename;
        }
    }
}